---
title: "Get Alerts"
api: "GET https://api-v2.opencopilot.so/backend/reports/:orgId/insights/alerts"
description: "Retrieve alerts based on predefined thresholds for chat sessions"
---
## Authentication

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Query Parameters

<ParamField query="startDate" type="string" format="date-time" optional>
  The start date for the date range to fetch alerts (ISO 8601 format)
</ParamField>

<ParamField query="endDate" type="string" format="date-time" optional>
  The end date for the date range to fetch alerts (ISO 8601 format)
</ParamField>

### Path Parameters

<ParamField path="orgId" type="string" required>
  The ID of the organization
</ParamField>

### Response

<ResponseField name="alerts" type="array">
  <ResponseField name="type" type="string">
    The type of alert (e.g., "LongWaitTime")
  </ResponseField>
  <ResponseField name="session_id" type="string">
    The ID of the chat session that triggered the alert
  </ResponseField>
  <ResponseField name="wait_time" type="number">
    The wait time in milliseconds (for LongWaitTime alerts)
  </ResponseField>
</ResponseField>

### Response Examples

<CodeGroup>
```json 200 OK
{
  "alerts": [
    {
      "type": "LongWaitTime",
      "session_id": "5f3e9c1b-7c1d-4e3f-8f9a-1a2b3c4d5e6f",
      "wait_time": 1200000
    },
    {
      "type": "LongWaitTime",
      "session_id": "6a7b8c9d-0e1f-2g3h-4i5j-6k7l8m9n0o1p",
      "wait_time": 900000
    }
  ]
}
```
</CodeGroup>

### Error Responses

<CodeGroup>
```json 401 Unauthorized
{
  "error": "Unauthorized",
  "message": "Invalid or missing authentication token"
}
```

```json 400 Bad Request
{
  "error": "Bad Request",
  "message": "Invalid date format for startDate or endDate"
}
```
</CodeGroup>

<RequestExample>

```bash cURL
curl --location --request GET 'https://api-v2.opencopilot.so/backend/reports/insights/alerts?startDate=2023-01-01T00:00:00Z&endDate=2023-12-31T23:59:59Z' \
--header 'Authorization: Bearer YOUR_TOKEN_HERE'
```

```javascript Node.js
const axios = require('axios');

const options = {
  method: 'GET',
  url: 'https://api-v2.opencopilot.so/backend/reports/insights/alerts',
  params: {
    startDate: '2023-01-01T00:00:00Z',
    endDate: '2023-12-31T23:59:59Z'
  },
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE'
  }
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});
```

</RequestExample>